package JDBCUtilsTest;
import JDBCUTILS.JDBCUtils;
import com.mysql.cj.jdbc.MysqlDataSource;
import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class jdbcConnectionTest {
    @Test
    public void testConnection(){
        Connection connection=JDBCUtils.getConnection();
        try {
            PreparedStatement preparedStatement=connection.prepareStatement
                    ("select*from student");
            ResultSet resultSet= preparedStatement.executeQuery();
            while(resultSet.next()){
                int id=resultSet.getInt("id");
                int sn=resultSet.getInt("sn");
                String name=resultSet.getString("name");
                System.out.println(id+"\t\t"+sn+"\t"+name);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
